package com.study.jvm.stringtable;

public class RuntimeStringTable {
    public static void main(String[] args) {
        String a = "a";
        String b = "b";
        //
        String addAb = new String("a") + new String("b");
        //new StringBuilder().append(a).append(b).toString();
        String heapAb = a + b;
        //尝试将堆中的对象方放入StringTable中如果有则直接返回引用，没有这生成后返回引用
        System.out.println(heapAb.hashCode());
        String abIntern = heapAb.intern();
        System.out.println(heapAb.hashCode());
        String ab = "ab";
        System.out.println(ab == addAb);
        System.out.println(ab == heapAb);
        System.out.println(abIntern == heapAb);
        System.out.println(ab == abIntern);

    }
}
